// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import Mint from 'mint-ui'
import 'mint-ui/lib/style.css'
import VueRouter from 'vue-router'
import router from './route'
import store from './store'
import VueResource from 'vue-resource'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'

Vue.use(Mint)
Vue.use(VueRouter)
Vue.use(VueResource)
Vue.use(ElementUI)

Vue.config.productionTip = false
//
/* eslint-disable no-new */
new Vue({
  el: '#app',
  data: {},
  router,
  store,
/*  render: c => c(App),*/
  render: function (h) {
    return h(App)
  },
  created () {
    this.checkLogin()
    console.log('vue实例')
  },
  methods: {
    checkLogin ()
    {
      //检查是否存在session
      //cookie操作方法在源码里有或者参考网上的即可
      if (!localStorage.getItem('user'))
      {
        //如果没有登录状态则跳转到登录页
        this.$router.push('/login')
      }else{
        //否则跳转到登录后的页面
        this.$router.push('/vue')
      }
    }
  },
/*  watch: {
    '$route' : 'checkLogin'
  }*/

})
